import store from '@/store'

export function actionToObject(json) {
  try {
    return JSON.parse(json)
  } catch (e) {
    console.log('err', e.message)
  }
  return []
}

/**
 * 控制按钮是否显示
 */
export function hasBtnPermission(permission) {
  const myBtns = store.getters.buttons
  const is_superuser = store.getters.is_superuser
  if (is_superuser === true) {
    return true
  }
  return myBtns.indexOf(permission) > -1
}
